/*******************************************OVERVIEW****************************************************************
 
"Reassessing the Link between Revolutionary Threats and Democratization" 
 
Replication File
 
Appendix F
 
  
********************************************************************************************************************/

clear
set more off
#delimit;


/*Set Directory -- You will need to adjust this line of code accordingly */; 

cd "/Users/YourFiles/Replication/";

/*Create Log File*/;

log using "Appendix F", replace text;


/*Load Data File - You will need to download AF's replicaton files*/;

/* https://www.econometricsociety.org/publications/econometrica/browse/2015/03/01/democratization-under-threat-revolution-evidence-great-reform */;

/*Please use the data file data_const.dta*/;


use "/Users/YourFiles/11484_Data_and_Programs/data/data_const.dta";


global baseline "share1826 share1826_2 reform_1830 county university narrow rottenindex h_index1831 primary secondary tetitary population1831 density1831 economictrend1 economictrend2"; 
global spatial "nearest_pc_km index1 market agg_type1 agg_type2";

loneway road county_id;

xtset county_id; 

/*Table 1*/;
 
regress constriots10 road, robust;


/*To Run the Following Command You Need to use Code in Angrit's Website*/;

/* https://economics.mit.edu/people/faculty/josh-angrist/mhe-data-archive*/;

/*Please download the zipped file containing the parametric Moulton (1986) correction factor. Then use the do and help files */;

moulton constriots10 road, cl(county_id);

xtreg constriots10 road, re;
 
regress constriots10 road, cluster(county_id); 
 
bootstrap, reps(1000): reg constriots10 road_dissevenoaks_const_km, cluster(county_id);

collapse constriots10 road [aw=county_id], by(county_id);

reg constriots10 road, robust;
 

 /*Weak Instrument Test*/;

 
use "/Users/YourFiles/11484_Data_and_Programs/data/data_const.dta", clear;
 
weakiv ivreg2 share1831  (constriots10 = road_dissevenoaks_const_km), cluster(county_id);

tf share1831 (constriots10 = road_d), cluster(county_id);
 

/*Validity*/;

plausexog ltz share1831 (constriots10 = road), mu(-.84) omega(0) vce(robust);

plausexog ltz share1831 (constriots10 = road), mu(0) omega(0) vce(cluster county_id);




log c;

